﻿using System;
using System.Linq;
using Stamp_For_Africa_Version_2.Models;

namespace Stamp_For_Africa_Version_2.Repositories
{
  public class CurrencyRepository
  {
    private StampsDataContext db = new StampsDataContext();
    //
    // Query Methods

    public IQueryable<Currency> FindAllCurrencies()
    {
      return db.Currencies;
    }

    public Currency GetCurrency(Guid id)
    {
      return db.Currencies.SingleOrDefault(d => d.Id == id);
    }

    //
    // Insert/Delete Methods

    public void Add(Currency currency)
    {
      db.Currencies.InsertOnSubmit(currency);
    }

    public void Delete(Currency currency)
    {
      db.Currencies.DeleteOnSubmit(currency);
    }

    //
    // Persistence

    public void Save()
    {
      db.SubmitChanges();
    }
  }
}